<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>机构管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#treeTable").treeTable({expandLevel : 2});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
	    	return false;
	    }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/office/">机构列表</a></li>
		<shiro:hasPermission name="sys:office:edit"><li><a href="${ctx}/sys/office/form">机构添加</a></li></shiro:hasPermission>
	</ul>
	<tags:message content="${message}"/>
	<table id="treeTable" class="table table-striped table-bordered table-condensed">
		<tr><th>机构名称</th>
		<th>归属区域</th>
		<th>机构编码</th>
		<th>机构类型</th>
		<th>备注</th><shiro:hasPermission name="sys:office:edit">
		<th>操作</th></shiro:hasPermission></tr>
		<c:forEach items="${list}" var="office">
			<tr id="${office.id}" pId="${office.parent.id ne requestScope.office.id?office.parent.id:'0'}">
				<td><a href="${ctx}/sys/office/form?id=${office.id}">${office.name}</a></td>
				<td>${office.area.name}</td>
				<td>${office.code}</td>
				<td>${dic:getDictLabel(office.officeType, 'sys_office_type', '无')}</td>
				<td style="max-width:300px;">${office.remarks}</td>
				<shiro:hasPermission name="sys:office:edit"><td>
					<a href="${ctx}/sys/office/form?id=${office.id}">修改</a>
					<%-- <a href="${ctx}/sys/office/delete?id=${office.id}" onclick="return confirmx('要删除该机构及所有子机构项吗？', this.href)">删除</a> --%>
					<a href="${ctx}/sys/office/form?parent.id=${office.id}">添加下级机构</a>
					<a href="javascript:;" onclick="makeqr(${office.id},'${office.name}')">生成二维码</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
	</table>

	<script>
		function makeqr(id,name){
            top.$.jBox.tip("正在生成,请稍等",'info');
            var url="${ctx}/sys/office/qr?id="+id;
            $.get(url,function(data){
                top.$.jBox.open("iframe:"+data,name+"的二维码",431,521,{
                        buttons:{"关闭":true}, loaded:function(h){
                            $(".jbox-content", top.document).css("overflow-y","hidden");
                        }
                    });
            })
		}
	</script>
</body>
</html>